<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/7/7
 * Time: 11:51
 */

global $_W,$_GPC;
$_GPC['do'] = 'v_new';
if ($_GPC['act'] == 'edit') {
    $id = intval($_GPC['id']);
    if($_W['ispost']){
        $data = array();
        $data['uniacid'] = $_W['uniacid'];
        $data['create_time'] = time();
        if(!empty($id)){
            $data['id'] = $id;
            unset($data['create_time']);
        }
        M('member')->update($data);
        message('保存成功',$this->createWebUrl('v_new'),'success');
    }
    $item = M('member')->getInfo($id);
    include $this->template('web/task/v_new_edit');
    exit();
}
if ($_GPC['act'] == 'delete') {
    $id = intval($_GPC['id']);
    if(empty($id)){
        if($_W['ispost']){
            $data = array();
            $data['status'] = 1;
            $data['message'] = '参数错误';
            die(json_encode($data));
        }else{
            message('参数错误',referer(),'error');
        }
    }
    M('member')->delete($id);
    if($_W['ispost']){
        $data = array();
        $data['status'] = 1;
        $data['message'] = '操作成功';
        die(json_encode($data));
    }else{
        message('删除成功',referer(),'success');
    }
}
$page = !empty($_GPC['page'])?intval($_GPC['page']):1;
$where = "";
$list = M('member')->getList($page,$where);
include $this->template('web/task/v_new');